<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
  <head>
    <title>图书分类</title>
    
	<meta http-equiv="pragma" content="no-cache">
	<meta http-equiv="cache-control" content="no-cache">
	<meta http-equiv="expires" content="0">    
	<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
	<meta http-equiv="description" content="This is my page">
	<meta http-equiv="content-type" content="text/html;charset=utf-8">
	<!--
	<link rel="stylesheet" type="text/css" href="styles.css">
	-->
<style type="text/css">
	body {
		font-size: 10pt;
		background: rgb(254,238,189);
	}
	.icon {
		margin:10px;
		border: solid 2px gray;
		width: 160px;
		height: 190px;
		text-align: center;
		float: left;
	}
</style>
      <script type="text/javascript" src="/adminjsps/js/jquery-3.2.1.min.js"></script>
  </head>
  
  <body>
   <%--<div class="icon">--%>
    <%--<a href="/adminjsps/admin/book/desc.jsp"><img src="/adminjsps/admin/book_img/8758723-1_l.jpg" border="0"/></a>--%>
      <%--<br/>--%>
   	<%--<a href="/adminjsps/admin/book/desc.jsp">Java就业培训教程</a>--%>
  <%--</div>--%>

  
  </body>
  <script>
      window.onload=function () {
          $.ajax({
              url:"/book",
              type:"get",
              success:function (re) {
                  console.log(re);
                  var i;
                  for (i = 0; i < re.data.length; i++) {
                      $(" <div class=\"icon\" id="+re.data[i].bid+" name="+re.data[i].bname+">\n" +
                          "    <a><img src=\""+re.data[i].image+"\" border=\"0\"/></a>\n" +
                          "      <br/>\n" +
                          "   \t<a>"+re.data[i].bname+"</a>\n" +
                          "  </div>").appendTo("body")
                  }
              }
          })
      }
      $("body").on("click","div",function () {
          var bid = $(this).attr("id");
          var bname = $(this).attr("name");
          console.log(bid);
          $.ajax({
              url:"/booksession",
              type:"get",
              data:{
                  bid:bid
              },
              success:function (re) {
                  console.log(re);
                  if (re.code) {
                      location.href="/adminjsps/admin/book/desc.jsp";
                  }
              }
          })
      })
  </script>
</html>

